有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java找不到参数的方法实现()

我试着运行我的应用程序,但gradle不想编写它

你能告诉我该怎么办吗

Error:(36, 0) Could not find method implementation() for arguments [com.google.firebase:firebase-appindexing:11.6.2] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

我的应用程序构建。梯度锉

 minSdkVersion 14
        targetSdkVersion 22
        signingConfig signingConfigs.config
    }
    buildTypes {
        release {
            debuggable false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-安卓.txt'), 'proguard-rules.txt'
            signingConfig signingConfigs.config
        }
    }
    lintOptions {
        disable 'MissingTranslation'
    }
    productFlavors {
    }
}
dependencies {
    implementation 'com.google.firebase:firebase-appindexing:11.6.2'
    compile project(':AndEngine')
    compile files('libs/gson-2.8.0.jar')
    compile 'com.安卓.support:support-v4:22.2.1'
    compile 'com.google.firebase:firebase-core:10.2.4'
    compile 'com.google.code.gson:gson:2.8.0'
    compile 'com.google.安卓.gms:play-services-ads:10.2.4'
    compile 'com.google.firebase:firebase-ads:10.2.4'
    compile 'com.google.firebase:firebase-crash:10.2.4'

} 

共 (1) 个答案

  1. # 1 楼答案

    替换

    implementation 'com.google.firebase:firebase-appindexing:11.6.2'
    

    compile 'com.google.firebase:firebase-appindexing:11.6.2'
    

    您需要更新gradle版本才能使用implementation。 可以在项目构建中更新构建脚本块。格拉德尔

    buildscript {
    
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.0.1'
    
    
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        }
    }
    

    compile已被弃用,未来的gradle版本将不再支持它

    <> P>因此,让您的项目编译只更改我建议的那一行,但是考虑更新您的分级版本,并使用^ {CD1>}为您的所有依赖项。

    更新

    firebase依赖项的所有模块都应该使用相同的版本

    所以你可能需要更新你的应用程序版本。往这边走

    dependencies {
        compile 'com.google.firebase:firebase-appindexing:11.6.2'
        compile project(':AndEngine')
        compile files('libs/gson-2.8.0.jar')
        compile 'com.android.support:support-v4:22.2.1'
        compile 'com.google.firebase:firebase-core:11.6.2'
        compile 'com.google.code.gson:gson:2.8.0'
        compile 'com.google.android.gms:play-services-ads:11.6.2'
        compile 'com.google.firebase:firebase-ads:11.6.2'
        compile 'com.google.firebase:firebase-crash:11.6.2'
    } 
    

    或者您可能有新的生成错误

    还有

    compile 'com.android.support:support-v4:22.2.1'
    

    不是最新版本,可能会带来新问题

    但我建议循序渐进:)

    更新2

    如果用这种方式声明gson的依赖项

    compile 'com.google.code.gson:gson:2.8.0'
    

    你不需要

    compile files('libs/gson-2.8.0.jar')
    

    它是多余的,而且你可以释放你的libs文件夹中无用的jar文件